export default {
    data(){
        return {
            dbVisible:false,
            partList:[]
        }
    },
    methods:{
        deleteItem(id){
            this.partList =  this.partList.filter(item=>item.id !== id)
        },
        add(list) {
            list.forEach(item=>{
                this.$set(item,'number',1);
            });
            if(this.partList.length) {
                this.partList.forEach(part => {
                    list.forEach((item,idx)=>{
                        if(item.partsNumber === part.partsNumber){
                            part.number = part.number ? part.number + 1 : 1;
                            list.splice(idx,1);
                        }
                    });
                });
                this.partList = this.partList.concat(list);
            } else {
                this.partList = this.partList.concat(list);
            }

            this.dbVisible = false;
        }
    }
}